﻿@{
    ViewBag.Title = "消息推送管理";
}
<form>
<input type="text" id="message" name="message" />
<select name="select" id="group">
    <option value="details1">分组1</option>
    <option value="details2">分组2</option>
</select>
<br>
<input type="button" value="广播消息!" onclick="return onSubmit()" />
<input type="button" value="分组广播!" onclick="onSubmitGroup()" />

<!----->

<div id="msmsg"></div>


<script src="@Url.Content("~/Scripts/jquery.signalR-1.1.4.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Signalr/Hubs")"></script>

<script>

    var pushHub = $.connection.pushHub;
    pushHub.client.notices = function (message) {
        //$("#msmsg").html(message);
        $("#msmsg").append("<p>" + message + "</p>")

    }
    $.connection.hub.start().done(function () {
        pushHub.server.addToGroup("server");
    });


</script>
<!----->
</form>
<script>
    function onSubmit() {
        $.ajax({
            url: '/Push/Push',
            data: { msg: $("#message").val() },
            type: 'post',
            dataType: 'json',
            success: function (result) {
            }
        })
        return false;
    }
    function onSubmitGroup() {
        $.ajax({
            url: '/Push/PushGroup',
            data: { msg: $("#message").val(), "group": $("#group").val() },
            type: 'post',
            dataType: 'json',
            success: function (result) {
            }
        })
        return false;
    }
</script>
